package com.medishare.adapter;

import java.util.ArrayList;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.medishare.R;
import com.medishare.activity.MainActivity;
import com.medishare.data.DataDoctorNotice;
import com.medishare.data.DataMediReminder;
import com.medishare.fragment.FragmentCallCenter;
import com.medishare.util.Utils;

import android.app.Fragment;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterDoctorNotice extends BaseAdapter {
	private Context mContext;
	private ArrayList<DataDoctorNotice> mData;
	private LayoutInflater mInflater;
    public AdapterDoctorNotice(Context context,ArrayList<DataDoctorNotice> datas){
    	this.mContext = context;
    	this.mData = datas;
    	mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public DataMediReminder getItem(int position) {
		mData.get(position);
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		DataDoctorNotice data = mData.get(position);
		if(convertView == null){
			convertView = mInflater.inflate(R.layout.listview_item_doctor_notice, null);
			holder = new ViewHolder();
			holder.createTime = (TextView) convertView.findViewById(R.id.create_time);
			holder.title = (TextView) convertView.findViewById(R.id.title);
			holder.time = (TextView) convertView.findViewById(R.id.time);
			holder.type = (TextView) convertView.findViewById(R.id.type);
			holder.address = (TextView) convertView.findViewById(R.id.address);
			holder.doctor = (TextView) convertView.findViewById(R.id.doctor);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.createTime.setText(Utils.convertTime(data.getUpdate_time()));
		holder.title.setText(String.format(mContext.getResources().getString(R.string.title_doctor_notice), data.getName()));
		holder.time.setText(data.getTime());
		holder.type.setText(data.getType());
		holder.address.setText(data.getAddress());
		holder.doctor.setText(data.getDoctor());
		return convertView;
	}
    
	
	static class ViewHolder{
		public TextView createTime;
		public TextView title;
		public TextView time;
		public TextView type;
		public TextView address;
		public TextView doctor;
	}
	
	
	
	
}
